﻿Public Class ObjetoPersistente

#Region "atributos"

    Private mOid As Integer

#End Region

#Region "constructor"

    Public Sub New()
        oid = 0
    End Sub

#End Region

#Region "properties"

    Public Property OID() As Integer
        Get
            Return mOid
        End Get
        Set(ByVal value As Integer)
            mOid = value
        End Set
    End Property

#End Region

#Region "metodos"

    'agrega un nuevo objeto a la base
    Public Sub added()
        Sistema.getPersistencia().add(Me)
    End Sub

    'modifica un objeto en la base
    Public Sub updated()
        Sistema.getPersistencia().update(Me)
    End Sub

    'elimina un objeto de la base
    Public Sub removed()
        Sistema.getPersistencia().delete(Me)
    End Sub

    'recupera todos los datos de un objeto de la base
    Public Sub recovered()
        Sistema.getPersistencia().bringData(Me)
    End Sub

    'obtiene el ultimo id de la tabla correspondiente al objeto
    Public Function getLastId() As Integer
        Return Sistema.getPersistencia().bringLastOID(Me)
    End Function

    Public Overloads Function equals(ByVal obj As Object) As Boolean
        Return Me.OID = CType(obj, ObjetoPersistente).OID
    End Function

#End Region

End Class
